//
//  YQPPFirstViewController.m
//  项目基础框架
//
//  Created by NetEase on 16/3/10.
//  Copyright © 2016年 NetEase-yangqian. All rights reserved.
//

#import "YQPPFirstViewController.h"
#import "EXFirstOneViewController.h"
#import "EXFirstTwoViewController.h"
#import "EXFirstThirdViewController.h"
#import "EXFirstFourViewController.h"
#import "EXRefreshControl.h"

static NSString *const cellIdentifer = @"cellIdentifer";
@interface YQPPFirstViewController ()

@property (nonatomic,strong) EXRefreshControl *control;

@end

@implementation YQPPFirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"首页";
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifer];
    
    self.control = [[EXRefreshControl alloc] initWithFrame:CGRectZero];
    [self.control addTarget:self action:@selector(loadNewData) forControlEvents:UIControlEventValueChanged];
    [self.tableView addSubview:self.control];
}

- (void)loadNewData {
    NSLog(@"new data");
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.control endRefresh];
    });
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifer forIndexPath:indexPath];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    switch (indexPath.row) {
        case 0:
            cell.textLabel.text = @"圆形，点击变大变变小，随手指移动";
            break;
        case 1:
        {
            cell.textLabel.text = @"圆形图片绘制，阴影";
        }
            break;
        case 2:
        {
            cell.textLabel.text = @"基础动画";
        }
            break;
        case 3: {
            cell.textLabel.text = @"自定义刷新控件";
        }
            break;
        default:
            break;
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0: {
            EXFirstOneViewController *vc = [[EXFirstOneViewController alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1: {
            EXFirstTwoViewController *vc = [[EXFirstTwoViewController alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 2: {
            EXFirstThirdViewController *vc=  [[EXFirstThirdViewController alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 3: {
            EXFirstFourViewController *vc = [[EXFirstFourViewController alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        default:
            break;
    }
}


@end
